package com.example.spareparts.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.spareparts.entity.OutBoundRecords;
import com.example.spareparts.service.OutBoundRecordsService;
import java.util.List;
@RestController
@RequestMapping("/api/outboundrecords")
public class OutBoundRecordsController {
    @Autowired
    private OutBoundRecordsService outBoundRecordsService;
    @GetMapping ("/listall")
    public List<OutBoundRecords> findAllOutBoundRecords(){
        return outBoundRecordsService.findAllOutBoundRecords();
    }
    @PostMapping("/insert")
    public void insertOutBoundRecord(@RequestBody OutBoundRecords outBoundRecord){
        outBoundRecordsService.insertOutBoundRecord(outBoundRecord);
    }
    @PutMapping ("/update/{outboundid}")
    public void updateOutBoundRecord(@PathVariable Long outboundid, @RequestBody OutBoundRecords outBoundRecord){
        outBoundRecord.setOutboundid(outboundid);
        outBoundRecordsService.updateOutBoundRecord(outBoundRecord);

    }
    @DeleteMapping ("/delete/{outboundid}")
    public void deleteOutBoundRecord(@PathVariable Long outboundid){
        outBoundRecordsService.deleteOutBoundRecord(outboundid);
    }
    @GetMapping ("/findbyid/{outboundid}")
    public OutBoundRecords findOutBoundRecordById(@PathVariable Long outboundid){
        return outBoundRecordsService.findOutBoundRecordById(outboundid);
    }
    @GetMapping ("/findbysparepartid/{sparepartid}")
    public List<OutBoundRecords> findOutBoundRecordBySparePartId(@PathVariable Long sparepartid){
        return outBoundRecordsService.findOutBoundRecordBySparePartId(sparepartid);
    }
    @GetMapping ("/findbybatchnumber/{batchNumber}")
    public OutBoundRecords findOutBoundRecordByBatchNumber(@PathVariable String batchNumber){
        return outBoundRecordsService.findOutBoundRecordByBatchNumber(batchNumber);
    }

}
